import networkx as nx

class PreferentialAttachmentEdgeGen(object):


    def __init__(self, numEdgesPerNode):
        '''
        Constructor
        '''
        
        self.NumEdgesPerNode = numEdgesPerNode
        
    def Apply(self, network):
        prefGraph = nx.barabasi_albert_graph(len(network.agentList), self.NumEdgesPerNode)
        
        for edge in prefGraph.edges_iter():
            nodeU = network.agentList[edge[0]]
            nodeV = network.agentList[edge[1]]
            network.graph.add_edge(nodeU, nodeV)
            network.graph.add_edge(nodeV, nodeU)